import os
from common.base import webdriver, By, sleep

driver = webdriver.Chrome()
driver.maximize_window()
url = 'file:///' + os.path.abspath('html') + '/popup.html'
driver.get(url)
# 通过标签名查找button按钮
btn = driver.find_elements(By.TAG_NAME, 'button')
btn[0].click()
sleep(2)
# 点击确定
driver.switch_to.alert.accept()
btn[1].click()
sleep(2)
# 点击取消
driver.switch_to.alert.dismiss()
btn[2].click()
sleep(2)
alert = driver.switch_to.alert
# 输入内容,有兼容性问题
alert.send_keys('ok')
alert.accept()
driver.quit()